﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using CE.User;
using CE.Global;
using CE.Provider;

public partial class Provider_CarInsurance_ViewUserResultSummaryReport : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserId] == null || Session[CE.Global.General.UserTypeId] == null)
        {
            Response.Redirect("~/Admin/AdminSecureLogin.aspx");
        }
        if (!IsPostBack)
        {
            ddlYear.Items.Clear();
            int _year = DateTime.Now.Year;
            ddlYear.Items.Add(new ListItem("All", "0000"));
            ddlYear.Items.Add(new ListItem(_year.ToString(), _year.ToString()));
            _year = _year - 1;
            ddlYear.Items.Add(new ListItem(_year.ToString(), _year.ToString()));

            //LoadProviderList();
            //ddlProviderName.Items.Insert(0, new ListItem("All", "0"));
            //ddlProviderId.Items.Insert(0, new ListItem("All", "0"));
            ddlDay.Text = "00";
            ddlMonth.Text = DateTime.Now.Month.ToString("00");
            ddlYear.Text = DateTime.Now.Year.ToString("0000");
            //txtModifiedDate.Text = " ";
            //grvUserResult.DataBind();
            Button1_Click(this, null);
        }
    }

    protected void ibtBack_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("~/Provider/CarInsurance/Log/ViewLogs.aspx");
    }



    //protected void LoadProviderList()
    //{
    //    ProviderCompanyLinkDB _procomdb = new ProviderCompanyLinkDB();
    //    DataTable _dtProvider = new DataTable("ProviderList");
    //    DataTable _dtList = new DataTable();
    //    _dtList.Columns.Add("Name");
    //    _dtList.Columns.Add("Email");

    //    DataTable _dtIDList = new DataTable();
    //    _dtIDList.Columns.Add("Name");
    //    _dtIDList.Columns.Add("CEID");

    //    _dtProvider = _procomdb.GetProviderList(Convert.ToInt64(Session[General.ProviderCompanyId].ToString()));
    //    for (int i = 0; i < _dtProvider.Rows.Count; i++)
    //    {
    //        ProfileDB _profiledb = new ProfileDB();
    //        Profile _profile = new Profile();
    //        _profile = _profiledb.GetProfile(Convert.ToInt64(_dtProvider.Rows[i]["CEID"].ToString()));

    //        Contact _contact = new Contact();
    //        ContactDB _contactdb = new ContactDB();
    //        _contact = _contactdb.GetContact(Convert.ToInt64(_dtProvider.Rows[i]["CEID"].ToString()));

    //        if (_profile != null && _contact != null)
    //        {
    //            DataRow _dtRow = _dtList.NewRow();
    //            _dtRow["Name"] = _profile.Salutation + " " + _profile.SurName + " " + _profile.FirstName;
    //            _dtRow["Email"] = _contact.Email;
    //            _dtList.Rows.Add(_dtRow);

    //            DataRow _dtIDRow = _dtIDList.NewRow();
    //            _dtIDRow["Name"] = _profile.Salutation + " " + _profile.SurName + " " + _profile.FirstName;
    //            _dtIDRow["CEID"] = _dtProvider.Rows[i]["CEID"].ToString();
    //            _dtIDList.Rows.Add(_dtIDRow);
    //        }

    //        _profiledb = null;
    //        _contact = null;
    //    }
    //    ddlProviderName.DataSource = null;
    //    ddlProviderName.DataSource = _dtList;
    //    ddlProviderName.DataTextField = "Name";
    //    ddlProviderName.DataValueField = "Email";
    //    ddlProviderName.DataBind();

    //    ddlProviderId.DataSource = null;
    //    ddlProviderId.DataSource = _dtIDList;
    //    ddlProviderId.DataTextField = "Name";
    //    ddlProviderId.DataValueField = "CEID";
    //    ddlProviderId.DataBind();

    //    //ddlProviderName.Items.Insert(0, new ListItem(" ", "-1"));
    //    //ddlProviderId.Items.Insert(0, new ListItem(" ", "-1"));
    //    lblProviderEmailAddress.Text = "";
    //    //}
    //    //else
    //    //{
    //    //    ddlProviderName.DataSource = null;
    //    //    lblProviderEmailAddress.Text = "";
    //    //}
    //}

    //protected void ddlProviderName_SelectedIndexChanged(object sender, EventArgs e)
    //{
    //    if (ddlProviderName.SelectedIndex > 0)
    //    {
    //        lblProviderEmailAddress.Text = ddlProviderName.SelectedValue;
    //    }
    //    else
    //    {
    //        lblProviderEmailAddress.Text = "";
    //    }
    //    ddlProviderId.SelectedIndex = ddlProviderName.SelectedIndex;
    //}

    protected void Button1_Click(object sender, EventArgs e)
    {
        txtModifiedDate.Text = " ";
        if (ddlYear.SelectedIndex > 0)
        {
            txtModifiedDate.Text = ddlYear.Text;
            if (ddlMonth.SelectedIndex > 0)
            {
                txtModifiedDate.Text += ddlMonth.Text;
                if (ddlDay.SelectedIndex > 0)
                {
                    txtModifiedDate.Text += ddlDay.Text;
                }
                else
                {
                    ddlDay.SelectedIndex = 0;
                }
            }
            else
            {
                ddlMonth.SelectedIndex = 0;
                ddlDay.SelectedIndex = 0;
            }
        }
        else
        {
            ddlMonth.SelectedIndex = 0;
            ddlDay.SelectedIndex = 0;
        }
        grvUserResult.DataBind();
    }

    //protected void grvUserResult_RowDataBound(object sender, GridViewRowEventArgs e)
    //{
    //    if (e.Row.RowType == DataControlRowType.DataRow)
    //    {
    //        Label lblEmail = new Label();
    //        lblEmail = (Label)e.Row.FindControl("lblEmail");
    //        string _strEmail = DataBinder.Eval(e.Row.DataItem, "Email").ToString();
    //        lblEmail.Text = CE.Security.MySecurity.Decrypt(_strEmail, true);
    //    }
    //}
}
